<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>如风壁纸 - 我的收藏</title>
    <link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="css/styles.css">
</head>
<body class="bg-gray-50 text-gray-900 font-sans">
    <div id="app" class="phone-container relative overflow-hidden mx-auto">
        <!-- Status Bar -->
        <div id="status-bar" class="status-bar flex justify-between items-center px-5 py-1 bg-black bg-opacity-10 text-white text-xs">
            <span id="time">9:41</span>
            <div class="status-icons flex space-x-1">
                <span><i class="fas fa-signal"></i></span>
                <span><i class="fas fa-wifi"></i></span>
                <span><i class="fas fa-battery-three-quarters"></i></span>
            </div>
        </div>

        <!-- Main Content Area -->
        <div id="content" class="content-area bg-white">
            <!-- Favorites Content -->
            <div id="favorites-container">
                <!-- This will either show the favorites or an empty state message -->
            </div>
        </div>

        <!-- Tab Bar -->
        <div id="tab-bar" class="tab-bar flex justify-around items-center px-2 py-3 bg-white border-t border-gray-200">
            <a href="home.html" class="tab-item flex flex-col items-center text-gray-500">
                <i class="fas fa-home text-lg"></i>
                <span class="text-xs mt-1">首页</span>
            </a>
            <a href="categories.html" class="tab-item flex flex-col items-center text-gray-500">
                <i class="fas fa-th-large text-lg"></i>
                <span class="text-xs mt-1">分类</span>
            </a>
            <a href="favorites.html" class="tab-item flex flex-col items-center text-blue-500">
                <i class="fas fa-heart text-lg"></i>
                <span class="text-xs mt-1">收藏</span>
            </a>
            <a href="settings.html" class="tab-item flex flex-col items-center text-gray-500">
                <i class="fas fa-cog text-lg"></i>
                <span class="text-xs mt-1">设置</span>
            </a>
        </div>
    </div>

    <script src="js/app.js"></script>
    <script>
        // Initialize clock for this page
        function updateClock() {
            const now = new Date();
            const hours = now.getHours().toString().padStart(2, '0');
            const minutes = now.getMinutes().toString().padStart(2, '0');
            document.getElementById('time').textContent = `${hours}:${minutes}`;
        }
        
        // Update clock
        updateClock();
        setInterval(updateClock, 60000);
        
        // Get favorites from localStorage
        const favorites = JSON.parse(localStorage.getItem('favorites') || '[]');
        const favoritesContainer = document.getElementById('favorites-container');
        
        // Render favorites or empty state
        if (favorites.length === 0) {
            // Empty state
            favoritesContainer.innerHTML = `
                <div class="empty-state">
                    <i class="fas fa-heart-broken"></i>
                    <h2 class="text-xl font-semibold mb-2">暂无收藏</h2>
                    <p class="text-sm">当您收藏壁纸后，将会显示在这里</p>
                </div>
            `;
        } else {
            // Show favorites
            favoritesContainer.innerHTML = `
                <div class="p-4">
                    <h1 class="text-2xl font-bold mb-4">我的收藏</h1>
                    
                    <div class="wallpaper-grid">
                        ${favorites.map(wallpaper => `
                            <div class="wallpaper-item" data-id="${wallpaper.id}">
                                <img src="${wallpaper.url}" alt="Wallpaper" loading="lazy" />
                            </div>
                        `).join('')}
                    </div>
                </div>
            `;
            
            // Add event listeners to wallpaper items
            document.querySelectorAll('.wallpaper-item').forEach(item => {
                item.addEventListener('click', () => {
                    const id = item.getAttribute('data-id');
                    window.location.href = `detail.html?id=${id}`;
                });
            });
        }
    </script>
</body>
</html> 